/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package african11;

import java.io.IOException;
import static chanlib.Chan_IO.*;

/**
 * @author robit
 */
public class BuildingAHouse{
    /*
      All neccesary to be defined
      including:
      variable, inner class
    */
    // static int A;
    // static void B();
    // static class C

    /*
       One calculation fits all of the cases.
    */
    static void preReckon(){
        return;
    }

    /*
      calculate the answer
    */
    private static void reckon(int line) {
        int L=Int();
        int W=Int();
        boolean maps[][]=new boolean[W][L];
        for(int i=0;i<W;i++){
            String tmp=String();
            for(int j=0;j<L;j++){
                switch(tmp.charAt(j)){
                    case 'G': case 'S':            
                        maps[i][j]=true;
                        break;
                }
            }
        }
        int MAX=50;
        int largsqr[][]=new int[W][L];        
        for(int i=0;i<W;i++)
        for(int j=0;j<L;j++){
            if(!maps[i][j])continue;
            int ext=MAX;
            if(i-1>=0&&j-1>=0){
                ext=Math.min(ext, largsqr[i-1][j]);
                ext=Math.min(ext, largsqr[i-1][j-1]);
                ext = Math.min(ext, largsqr[i][j - 1]);
            }            
            else ext=0;

            largsqr[i][j]=ext+1;            
        }
        
        int largest=0;
        for(int i=0;i<W;i++)
        for(int j=0;j<L;j++)
        {
            if(!maps[i][j])continue;

            for(int k=largsqr[i][j];k>0;k--){
            // scan vertically
            int jj=j-k;
            while(jj>=0){
                int ii=i-k+1;
                while(ii<=i&&maps[ii][jj])ii++;
                if(ii!=i+1)break;
                jj--;
            }
            largest=Math.max(largest,(j-jj)*k);
            // scan horizontally
            int  ii=i-k;
            while(ii>=0){
                jj=j-k+1;
                while(jj<=j&&maps[ii][jj])jj++;
                if(jj!=j+1)break;
                ii--;
            }
            largest=Math.max(largest,(i-ii)*k);
            }
        }
        
        String ans =""+largest;

        String output=String.format("Case #%d: %s",line,ans);
        writeln(output, OUTFILE);
        //writeln(String.format("N=%d K=%d\n%s", N, K, ans),ANALFILE);
        //println(output);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        /*
           Pre-computing for all cases
        */

        // Just in case!
        //preReckon();
        //while((char)read()!='P');

        /*
          Input-output
        */
        boolean test=false;
        boolean small=false;
        String prob="C";
        String filename;
        if(test) filename="test";
        else{
            if(small) filename=prob+"-small-practice";
            else filename=prob+"-large-practice";
        }
        try {
            /*
               Init IO,plus determination of input line number
             */
            int lineNums = initFileIO(filename);
            for (int i = 1; i <= lineNums; i++) {
                reckon(i);
            }
        } finally {
            endIO();
        }
    }

}
